Visual Basic (Declaration) | |
---|---|
Public Function GetEnumerator() As IEnumerator(Of KeyValuePair(Of TKey,TValue)) |
C# | |
---|---|
public IEnumerator<KeyValuePair<TKey,TValue>> GetEnumerator() |
BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs
C# | Copy Code |
---|---|
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options( new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer()); options.CalcBTreeOrder(32, 300); options.FileName = TempFile.TempPath; options.CreateFile = CreatePolicy.Always; using (TempFile copy = new TempFile()) { copy.Delete(); int minRecordCreated = StartAndAbortWriters(options, copy); using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy using (TempFile.Attach(copy.TempPath + ".deleted")) //renamed existing file { options.CreateFile = CreatePolicy.Never; int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options); if (recoveredRecords < RecordsCreated) Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated); options.FileName = copy.TempPath; recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options); Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords); using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options)) { dictionary.EnableCount(); Assert.AreEqual(recoveredRecords, dictionary.Count); foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary) { Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID); dictionary.Remove(kv.Key); } Assert.AreEqual(0, dictionary.Count); } } } |
VB.NET | Copy Code |
---|---|
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer()) options.CalcBTreeOrder(32, 300) options.FileName = TempFile.TempPath options.CreateFile = CreatePolicy.Always Using copy As New TempFile() copy.Delete() Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy) Using TempFile.Attach(copy.TempPath + ".recovered") 'used to create the new copy Using TempFile.Attach(copy.TempPath + ".deleted") 'renamed existing file options.CreateFile = CreatePolicy.Never Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options) If recoveredRecords < RecordsCreated Then Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated) End If options.FileName = copy.TempPath recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options) Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords) Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options) dictionary.EnableCount() Assert.AreEqual(recoveredRecords, dictionary.Count) For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID) dictionary.Remove(kv.Key) Next Assert.AreEqual(0, dictionary.Count) End Using End Using End Using End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7